package cn.ahaiahaixx.supemarketonline.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.ahaiahaixx.supemarketonline.aop.NeedAdminUser;
import cn.ahaiahaixx.supemarketonline.entity.TbAdminUser;
import cn.ahaiahaixx.supemarketonline.model.TbUserModel;
import cn.ahaiahaixx.supemarketonline.service.UserService;
import cn.ahaiahaixx.supemarketonline.utils.JsonMessage;

/**
 * 管理员操作操作
 * 
 * @author Aiden Pearce
 *
 */
@RestController
@RequestMapping("/tbadminuser")
public class AdminUserController implements NeedAdminUser {
//登录校验完成
  @Autowired
  private UserService userService;

  @RequestMapping("/query")
  public JsonMessage query(TbUserModel model) throws Exception {
    return userService.queryAll(model);
  }
  //完成

  @RequestMapping("/adminupdate")
  public JsonMessage adminupdate(TbUserModel model) throws Exception {
    return userService.adminupdate(model);
  }
  //{"tbUser.auid":"1","tbUser.username":"852","tbUser.password":"852","tbUser.nickname":"852"}
  //成功

  @RequestMapping("/admindelete")
  public JsonMessage admindelete(TbUserModel model) throws Exception {
    return userService.admindelete(model);
  }
  //{"tbUser.auid":"1"} 成功

  @RequestMapping("/nuadmindelete")
  public JsonMessage nuadmindelete(TbUserModel model) throws Exception {
    return userService.nuadmindelete(model);
  }
//{"tbUser.auid":"1"}成功
  private TbAdminUser user;

  @Override
  public void setUser(TbAdminUser user) {
    this.user = user;

  }

  @Override
  public TbAdminUser getUser() {
    return user;
  }
}
